/*
 * @lc app=leetcode.cn id=409 lang=typescript
 *
 * [409] 最长回文串
 */

// @lc code=start
function longestPalindrome(s: string): number {
    const arr = new Array(128).fill(0);
    for (let i = 0; i < s.length; i++) {
        const c = s.charCodeAt(i);
        arr[c]++;
    }

    let res = 0;
    for (let i of arr) {
        if (i === 0) {
            continue;
        }
        res += Math.floor(i / 2) * 2;
        if (i % 2 === 1 && res % 2 === 0) {
            res++;
        }
    }
    return res;
};

// @lc code=end

